package com.wow.app.promotion.web.personal.module.screen;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import com.alibaba.citrus.turbine.Context;
import com.alibaba.citrus.turbine.dataresolver.Param;
import com.wow.app.biz.common.SessionUser;
import com.wow.app.biz.common.SessionUtil;
import com.wow.app.biz.user.UserService;
import com.wow.app.dal.dto.UserDO;

public class UserInfo {
	@Resource
	UserService userService;

	public void execute(HttpSession httpSession, Context context,
			@Param("name") String name) {
		SessionUser sessionUser = SessionUtil.getSessionUser(httpSession);
		String userName = sessionUser.getLoginID();
		// 如果是管理员，则查询参数中指定的用户
		if (name != null && Integer.parseInt(sessionUser.getUserType()) == 0) {
			userName = name;
		}
		UserDO userDO = userService.getUserByName(userName);
		context.put("user", userDO);
	}
}